﻿using System.Collections.Generic;
using System.Diagnostics;
using System.Xml.Linq;
using System.Messaging;
using MSMQMessage = System.Messaging.Message;

namespace Klinkby.MicroBus
{
    static class XEx
    {
        public static string AttributeValue(this XElement e, XName name)
        {
            Debug.Assert(e != null || name != null);
            var a = e.Attribute(name);
            return a != null ? a.Value : null;
        }

        public static IEnumerable<MSMQMessage> GetMessageEnumerator3(this MessageQueue messageQueue)
        {
            using (var msgEnum = messageQueue.GetMessageEnumerator2())
                while (msgEnum.MoveNext())
                    yield return msgEnum.Current;
        }

    }
}
